#ifndef _FONT_H_
#define _FONT_H_

#include "common.h"
#include "graphics.h"

enum FontError
{
  FONT_ERROR_OK,
  FONT_ERROR_NOT_OPEN_FILE,
  FONT_ERROR_NOT_SET_SIZE,
  FONT_ERROR_NOT_GET_GLYPH,
};

enum TextHorzAlign
{
  TEXT_HORZ_ALIGN_LEFT,
  TEXT_HORZ_ALIGN_CENTER,
  TEXT_HORZ_ALIGN_RIGHT
};

enum TextVertAlign
{
  TEXT_VERT_ALIGN_TOP,
  TEXT_VERT_ALIGN_CENTER,
  TEXT_VERT_ALIGN_BOTTOM
};

struct Glyph
{
  int advance;
  Point offset;
  Rect pix_rect;
};

struct Metrics
{
  int line_height;
  int line_spacing;
};

struct Font
{
  Metrics metrics;
  Glyph glyph[96];
  Dimension tex_dim;
  Texture texture;
};

bool FontSystem_init();

const char* Font_getErrorMsg(FontError error);

void Font_init(Font* font);
void Font_free(Font* font);

bool Font_loadBmp(Font* font, const char* filename);
FontError Font_load(Font* font, unsigned size, const char* filename);

void Font_getTextDim(const Font& font, const char* text, Dimension* dim);

int Font_drawChar(const Font& font, const Point& pos, Colour colour, char c);
void Font_print(const Font& font, const Point& pos, Colour colour, const char* text);
void Font_print(const Font& font, const Rect& rect, TextHorzAlign horz_align,
  TextVertAlign vert_align, Colour colour, const char* text);

#endif
